package com.catsic.base.dao.impl;

import java.io.Serializable;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import com.catsic.base.dao.JdbcBaseDao;

public abstract class JdbcBaseDaoImpl<T, PK extends Serializable> implements
		JdbcBaseDao<T, PK> {
	
	@Autowired
	protected JdbcTemplate jdbcTemplate;
	
	@Autowired
	protected NamedParameterJdbcTemplate namedParameterJdbcTemplate;

	abstract public T get(PK id);

	abstract public void add(T t);

	abstract public void delete(PK id);

	abstract public void update(T t);

	abstract public Integer getTotalCount();

	abstract public List<T> getList(int startIndex, int count);

	abstract public List<T> getAll();

	@Override
	public void createTable() {
		String sql = "create table mytable (id integer, name varchar(100))";
		jdbcTemplate.execute(sql);
	}

	@Override
	public void callProcedure() {
		String sql = "call SUPPORT.REFRESH_ACTORS_SUMMARY(?)";
		jdbcTemplate.update(sql,Long.valueOf(1));
	}
}
